import { ProColumns } from '@ant-design/pro-table';
import React from 'react';
import { Button, Popconfirm } from 'antd';
import { useRequest } from '@/hooks/request';

export const tableColumns: ProColumns[] = [
  {
    dataIndex: 'number',
    title: '编号',
    order: 60,
  },
  {
    dataIndex: 'parentName',
    title: '家长姓名',
    order: 8,
  },
  {
    dataIndex: 'relationship',
    title: '关系',
    hideInSearch: true,
    valueEnum: {
      父亲: '父亲',
      母亲: '母亲',
    },
  },
  {
    dataIndex: 'phone',
    title: '手机号',
  },
  {
    dataIndex: 'name',
    title: '学生姓名',
    order: 50,
  },
  {
    dataIndex: 'sex',
    title: '性别',
    hideInSearch: true,
    valueEnum: {
      男: '男',
      女: '女',
    },
  },
  {
    dataIndex: 'birthday',
    title: '出生日期',
    hideInSearch: true,
  },
  {
    dataIndex: 'nation',
    title: '民族',
    hideInSearch: true,
  },
  {
    dataIndex: 'address',
    title: '家庭住址',
    hideInSearch: true,
  },
  {
    dataIndex: 'school',
    hideInSearch: true,
    title: '所在学校',
  },
  {
    dataIndex: 'store',
    title: '体验门店',
    hideInSearch: true,
  },
  {
    dataIndex: 'date',
    title: '体验时间',
    hideInSearch: true,
  },
  {
    dataIndex: 'leftBefore',
    title: '体验前左眼视力值',
    hideInSearch: true,
  },
  {
    dataIndex: 'leftBeforeAstigma',
    title: '体验前左眼散光',
    hideInSearch: true,
  },
  {
    dataIndex: 'rightBefore',
    title: '体验前右眼视力值',
    hideInSearch: true,
  },
  {
    dataIndex: 'rightBeforeAstigma',
    title: '体验前右眼散光',
    hideInSearch: true,
  },
  {
    dataIndex: 'leftAfter',
    title: '体验后左眼视力值',
    hideInSearch: true,
  },
  {
    dataIndex: 'rightAfter',
    title: '体验后右眼视力值',
    hideInSearch: true,
  },
  {
    dataIndex: 'amblyopia',
    title: '是否弱视',
    hideInSearch: true,
  },
  {
    dataIndex: 'amblyopiaMsg',
    title: '弱视值',
    hideInSearch: true,
  },
  {
    dataIndex: 'strabismus',
    title: '是否斜视',
    hideInSearch: true,
  },
  {
    dataIndex: 'strabismusMsg',
    title: '斜视值',
    hideInSearch: true,
  },
  {
    dataIndex: 'mydriasis',
    title: '是否散瞳',
    hideInSearch: true,
  },
  {
    dataIndex: 'mydriasisMsg',
    title: '散瞳值',
    hideInSearch: true,
  },
  {
    dataIndex: 'glasses',
    hideInSearch: true,
    title: '是否佩戴眼镜',
  },
  {
    dataIndex: 'glassesMsg',
    title: '眼镜值',
    hideInSearch: true,
  },
  {
    dataIndex: 'orthok',
    title: '是否佩戴OK镜',
    hideInSearch: true,
  },
  {
    dataIndex: 'orthokMsg',
    title: 'OK镜值',
    hideInSearch: true,
  },
  {
    dataIndex: 'otherMsg',
    title: '其他',
    hideInSearch: true,
  },
  {
    dataIndex: 'maternalInher',
    title: '父亲遗传',
    hideInSearch: true,
  },
  {
    dataIndex: 'paternalInher',
    title: '母亲遗传',
    hideInSearch: true,
  },
  {
    dataIndex: 'note',
    title: '备注',
    hideInSearch: true,
    width: 200,
  },
  {
    dataIndex: 'registrant',
    title: '登记人',
    hideInSearch: true,
    width: 200,
  },
  {
    dataIndex: 'regisTime',
    title: '登记时间',
    hideInSearch: true,
  },
  {
    title: '操作',
    valueType: 'option',
    fixed: 'right',
    width: 80,
    render: (text, record, _, action) => [
      <Popconfirm
        title={'确定删除吗'}
        onConfirm={async () => {
          await useRequest({
            url: `/health-record/${record.id}`,
            method: 'DELETE',
          });
          action?.reloadAndRest?.();
        }}
      >
        <Button danger type="link">
          删除
        </Button>
      </Popconfirm>,
    ],
  },
];
